/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nokia.iap.ui.lib.onebutton;

import com.nokia.mid.ui.DirectUtils;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;

/**
 *
 * @author zinin
 */
public class GxColorTheme {
    private int face = 0;
    private int style = 0;
    private int textHeight = 20;
    Font font;
    private final Display display;

    public GxColorTheme(Display clientDisplay){
        display = clientDisplay;
        font = DirectUtils.getFont(face, style, textHeight);
    }

    public void applyTheme(GxButtonDrawer button){
        button.setBackgroundColor(display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND));
        button.setForegroundColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
    }
    
    public Font getFont(){
        return font;
    }

    public int getBackgroundColor() {
        return display.getColor(Display.COLOR_BACKGROUND);
    }
    
    public static int lighten(int inColor, double amount)
    {
        // note color format is 0x00RRGGBB
        int r = inColor & 0xFF0000;
        int g = inColor & 0x00FF00;
        int b = inColor & 0x0000FF;
        
        r = (int) Math.min(0xFF, r + 0xFF * amount);
        g = (int) Math.min(0xFF, g + 0xFF * amount);
        b = (int) Math.min(0xFF, b + 0xFF * amount);
        
        int result = r | g | b;
        return result;
    }
}
